package com.moter.demo01.io.in_outputstream.pipedstream;



import java.io.IOException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;

public class PipedOutputStreamDemo {
    public static void main(String[] args){
        PipedOutputStream pipedOutputStream=null;
        PipedInputStream pipedInputStream = null;
        try {
            pipedInputStream = new PipedInputStream();
            pipedOutputStream = new PipedOutputStream();
            pipedInputStream.connect(pipedOutputStream);

            pipedOutputStream.write('2');
            int read = pipedInputStream.read();
            System.out.println((char) read);

        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                pipedOutputStream.close();
                pipedInputStream.close();
            }catch (IOException e){
                e.printStackTrace();
            }
        }
    }
}
